/*
 * CState.cpp
 *
 *  Created on: Nov 7, 2011
 *      Author: welcome
 */

#include "CState.h"

namespace GGEngine {

CState::CState() {

}

CState::~CState() {
	int count = triggerList.size();
	for (int i = 0; i < count; i++) {
		CTrigger* trigger = triggerList[i];
		if (trigger) {
			delete trigger;
			trigger = KD_NULL;
		}
	}
	triggerList.clear();
}
int CState::getTriggerCount() {
	return triggerList.size();
}
void CState::addTrigger(CTrigger *trigger) {
	triggerList.push_back(trigger);
}
CTrigger* CState::findTriggerWithID(int eventID) {

	int count = triggerList.size();

	for (int i = 0; i < count; i++) {
		CTrigger *trigger = triggerList[i];

		if ((trigger) && (trigger->getEventID() == eventID)) {
			return trigger;
		}
	}
	return KD_NULL;
}
}
